﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace Arcgis
{
    public partial class WelcomeForm : Form
    {
        private bool _isEnterClicked = false; // 新增标志位
        public WelcomeForm()
        {
            InitializeComponent();
        }

        private void WelcomeForm_Load(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            _isEnterClicked = true; // 设置进入标志
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void button2_Click(object sender, EventArgs e)
        {
            // 显示确认对话框
            DialogResult result = MessageBox.Show(
                "QAQ，您真的要退出吗？",            // 提示文本
                "退出确认",                      // 对话框标题
                MessageBoxButtons.YesNo,         // 显示是和否按钮
                MessageBoxIcon.Question,         // 问号图标
                MessageBoxDefaultButton.Button2); // 默认选中否

            // 根据用户选择执行操作
            if (result == DialogResult.Yes)
            {
                Application.Exit();  // 确认退出
            }
            // 否则不做任何操作
        }

        private void WelcomeForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            // 仅处理用户直接关闭窗口的情况
            if (e.CloseReason == CloseReason.UserClosing && !_isEnterClicked)
            {
                e.Cancel = true;
                button2.PerformClick();
            }
        }
    }
}
